﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Alex.Library.Cloud.Libs;

namespace Alex.Library.Cloud.VMWare.V51.VMMParameters
{
    public class ListVMParameter : IVMMParameter
    {
        public ListVMParameter()
        {
            errorMessage = new StringBuilder();
        }

        public string DataCenterName { get; set; }
        public bool IncludeTemplate { get; set; }
        
        public virtual bool IsValid()
        {
            if (String.IsNullOrEmpty(DataCenterName))
            {
                errorMessage.AppendLine("DataCenterName is empty or null.");
                return false;
            }
            return true;
        }

        protected StringBuilder errorMessage;
        public string ErrorMessage
        {
            get { return errorMessage.ToString(); }
        }
    }

    public class FindVMParameter : IVMMParameter
    {
        public string VMName { get; set; }
        public string DataCenterName { get; set; }

        public bool IsValid()
        {
            bool res = true;
            StringBuilder sb = new StringBuilder();
            if (String.IsNullOrEmpty(VMName))
            {
                sb.AppendLine("VMName is empty or null.");
                res = false;
            }
            if (String.IsNullOrEmpty(DataCenterName))
            {
                sb.AppendLine("DataCenterName is empty or null.");
                return false;
            }
            ErrorMessage = sb.ToString();
            return res;
        }

        public string ErrorMessage { get; private set; }
    }

    public class ListTemplateVMParameter : IVMMParameter
    {        
        public string DataCenterName { get; set; }

        public bool IsValid()
        {
            bool res = true;
            StringBuilder sb = new StringBuilder();            
            if (String.IsNullOrEmpty(DataCenterName))
            {
                sb.AppendLine("DataCenterName is empty or null.");
                return false;
            }
            ErrorMessage = sb.ToString();
            return res;
        }

        public string ErrorMessage { get; private set; }
    }
}
